package com.atguigu.springboot.controller;

import com.atguigu.springboot.bean.Employee;
import com.atguigu.springboot.mapper.EmployeeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class EmployeeController {

    @Autowired
    private EmployeeMapper employeeMapper ;

    @RequestMapping("/emp/{id}")
    public Employee getEmp(@PathVariable Integer id) {
        return employeeMapper.getEmpById(id) ;
    }

    @RequestMapping("/emp")
    public Employee insertEmployee(Employee employee) {
        employeeMapper.insertEmp(employee) ;
        return employee ;
    }
}
